<template>
  <div class="movie_body">
    <Loading v-if="isLoading" />
    <Scroller v-else>
      <ul>
        <li v-for="item in comingFilm" :key="item.id">
          <div class="pic_show" @click="handleToDetail(item.id)">
            <img :src="item.img | setWH('128.180')" />
          </div>
          <div class="info_list">
            <h2 class="move_name" @click="handleToDetail(item.id)">
              {{ item.nm }}
            </h2>
            <p>
              <span class="person">{{ item.wish }}</span
              >人想看
            </p>
            <p>上映日期：{{ item.comingTitle }}</p>
          </div>
          <div class="btn_pre">预售</div>
        </li>
      </ul>
    </Scroller>
  </div>
</template>

<script>
export default {
  name: "ComingSoon",
  data() {
    return {
      comingFilm: [],
      isLoading: true,
      prevCityId: -1,
    };
  },
  activated() {
    var cityId = this.$store.state.city.id;
    if (this.prevCityId === cityId) return;
    this.axios
      .get("/ajax/ajax/comingList?ci=" + cityId + "&limit=10&offset=0&token=")
      .then((res) => {
        if (res.statusText) {
          this.comingFilm = res.data.coming;
          this.isLoading = false;
          this.prevCityId = cityId;
        }
      });
  },
  methods: {
    handleToDetail(movieId) {
      this.$router.push("/movie/Detail/2/" + movieId);
    },
  },
};
</script>

<style scoped lang="scss">
.movie_body {
  flex: 1;
  overflow: auto;
  ul {
    margin: 0 12px;
    overflow: hidden;
    li {
      display: flex;
      margin-top: 12px;
      padding-bottom: 10px;
      border-bottom: 1px solid #e6e6e6;
      align-items: center;
      .pic_show {
        width: 64px;
        height: 90px;
        img {
          width: 100%;
          display: block;
        }
      }
      .info_list {
        margin-left: 10px;
        flex: 1;
        h2 {
          font-size: 17px;
          width: 150px;
          line-height: 24px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        p {
          font-size: 13px;
          width: 200px;
          line-height: 22px;
          color: #666;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          .person {
            font-size: 15px;
            color: #faaf00;
            font-weight: bold;
          }
        }
      }
      .btn_pre {
        width: 47px;
        height: 27px;
        background: #3c9fe6;
        color: white;
        border-radius: 4px;
        font-size: 12px;
        text-align: center;
        line-height: 28px;
      }
    }
  }
}
</style>